<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>

    /* 
    p.__proto__=Person.prototype

    Person.prototype对象包括
    {
      constructor:指向Person本身
      __proto__:
    }
    
    */


    function Person() { };
    function Student() { };
    var p = new Person(); // Student.prototype = Object.create(Person.prototype)
    console.log(p);
    // Student.prototype = p; //继承原型
    Student.prototype = Object.create(Person.prototype)
    Student.prototype.constructor = Student // 改变原型中constructor指向
    var s = new Student();
    console.log(s);


    // 原型模式

    var prototype = {
      name: 'Jack',
      getName: function () {
        return this.name
      }
    }

    var obj = Object.create(prototype, {
      job: {
        value: 'IT'
      }
    })

    console.log(obj);
    console.log(obj.getName())  // Jack
    console.log(obj.job)  // IT
    console.log(obj.__proto__ === prototype)  //true
  </script>
</body>

</html>